/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author SONY
 */
@Entity
@Table(name = "SaleOrderDetail")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SaleOrderDetail.findAll", query = "SELECT s FROM SaleOrderDetail s"),
    @NamedQuery(name = "SaleOrderDetail.findBySaleOrderDetailID", query = "SELECT s FROM SaleOrderDetail s WHERE s.saleOrderDetailID = :saleOrderDetailID"),
    @NamedQuery(name = "SaleOrderDetail.findByOrderQty", query = "SELECT s FROM SaleOrderDetail s WHERE s.orderQty = :orderQty"),
    @NamedQuery(name = "SaleOrderDetail.findByLineTotal", query = "SELECT s FROM SaleOrderDetail s WHERE s.lineTotal = :lineTotal")})
public class SaleOrderDetail implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "SaleOrderDetailID")
    private Integer saleOrderDetailID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "OrderQty")
    private int orderQty;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "LineTotal")
    private BigDecimal lineTotal;
    @JoinColumn(name = "SaleOrderID", referencedColumnName = "SaleOrderID")
    @ManyToOne(optional = false)
    private SaleOrder saleOrderID;
    @JoinColumn(name = "ProductID", referencedColumnName = "ProductID")
    @ManyToOne(optional = false)
    private Product productID;

    public SaleOrderDetail() {
    }

    public SaleOrderDetail(Integer saleOrderDetailID) {
        this.saleOrderDetailID = saleOrderDetailID;
    }

    public SaleOrderDetail(Integer saleOrderDetailID, int orderQty, BigDecimal lineTotal) {
        this.saleOrderDetailID = saleOrderDetailID;
        this.orderQty = orderQty;
        this.lineTotal = lineTotal;
    }

    public Integer getSaleOrderDetailID() {
        return saleOrderDetailID;
    }

    public void setSaleOrderDetailID(Integer saleOrderDetailID) {
        this.saleOrderDetailID = saleOrderDetailID;
    }

    public int getOrderQty() {
        return orderQty;
    }

    public void setOrderQty(int orderQty) {
        this.orderQty = orderQty;
    }

    public BigDecimal getLineTotal() {
        return lineTotal;
    }

    public void setLineTotal(BigDecimal lineTotal) {
        this.lineTotal = lineTotal;
    }

    public SaleOrder getSaleOrderID() {
        return saleOrderID;
    }

    public void setSaleOrderID(SaleOrder saleOrderID) {
        this.saleOrderID = saleOrderID;
    }

    public Product getProductID() {
        return productID;
    }

    public void setProductID(Product productID) {
        this.productID = productID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (saleOrderDetailID != null ? saleOrderDetailID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SaleOrderDetail)) {
            return false;
        }
        SaleOrderDetail other = (SaleOrderDetail) object;
        if ((this.saleOrderDetailID == null && other.saleOrderDetailID != null) || (this.saleOrderDetailID != null && !this.saleOrderDetailID.equals(other.saleOrderDetailID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.SaleOrderDetail[ saleOrderDetailID=" + saleOrderDetailID + " ]";
    }
    
}
